﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class MasterPages_MasterPage1 : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GlobalFunctions gf = new GlobalFunctions();
        if (gf.IsLogin() == 1 || GlobalFunctions.GetCurrentPageName() == "NguoiDung_DangNhap.aspx")
            LoginInterface1.Visible = false;
        else
            LoginInterface1.Visible = true;

        if (gf.IsKHDC() == 0)
            ChucNangKHDC1.Visible = false;
        if (gf.IsKHTT() == 0)
            ChucNangKHTT1.Visible = false;

        DataDSTableAdapters.QUANGCAOTableAdapter qcAdapter = new DataDSTableAdapters.QUANGCAOTableAdapter();
        DataDS.QUANGCAODataTable qcTable = qcAdapter.GetData();
        //string[] str = new string[5];
        string str = "<table border='0' cellspacing='10' cellpadding='10' width='100%'>";
        for (int i = 0; i < qcTable.Rows.Count; i++ )
        {
            if ((bool)qcTable[i]["TrangThai"] == true)
            {
                //int vitri = int.Parse(qcTable[i]["Vitri"].ToString()) - 1;
                //str[vitri] = "<embed src='" + qcTable[i]["DuongDan"].ToString() + "' height='"+ qcTable[i]["Height"]+"' width='"+qcTable[i]["Width"]+"'/>";
                int vitri = int.Parse(qcTable[i]["Vitri"].ToString());
                if(vitri == 1)
                    lbQuangCao1.Text = "<embed src='" + qcTable[i]["DuongDan"].ToString() + "' height='" + qcTable[i]["Height"] + "' width='" + qcTable[i]["Width"] + "'/>";
                else
                    str+= "<tr><td><embed src='" + qcTable[i]["DuongDan"].ToString() + "' height='" + qcTable[i]["Height"] + "' width='" + qcTable[i]["Width"] + "'/></td></tr>";
            }
        }
        //<embed src="" height="46" width="348"/>
        str += "</table>";
        lbChuoiQuangCao.Text = str;
        //lbQuangCao1.Text = str[0];
        //lbQuangCao2.Text = str[1];
        //lbQuangCao3.Text = str[2];
        //lbQuangCao4.Text = str[3];
        //lbQuangCao5.Text = str[4];
        

    }
}
